/*
 * Copyright 2011 CraneLeeon authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.crane.webtemplate.action;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.crane.webtemplate.model.choice.Status;
import org.json.JSONException;
import org.json.JSONObject;

/**
 *
 * @author CraneLeeon
 */
@Action("/Home")
@Results({
    @Result(name = "page", type = "dispatcher", location = "Home.jsp"),
    @Result(name = "json", type = "dispatcher", location = "/WEB-INF/jsp/json.jsp"),
    @Result(name = "xml", type = "dispatcher", location = "/WEB-INF/jsp/xml.jsp")
})
public class Home extends BaseAction {
    protected static final Log logger = LogFactory.getLog(Home.class);

    

    public int getEditOptions_Status_Default() {
        return Status.DEFAULT.getIntvalue();
    }

    public String getEditOptions_Status() {
        JSONObject j = new JSONObject();
        JSONObject sb = new JSONObject();
        try {
            for (Status option : Status.values()) {
                sb.put(option.getIntvalue()+"", this.getText(option.toString())+ "=" + option.getIntvalue());
            }
            j.put("value", sb);
        } catch (JSONException ex) {
            logger.debug(ex);
        }
        return j.toString();
        
    }

   

    @Override
    public String execute() throws Exception {
        return "page";
    }


    @Override
    public Class getBoClass() {
        throw new UnsupportedOperationException("Not supported yet.");
    }


    
}
